package com.ymatou.iapi.im.testcase;

import com.ymatou.iapi.im.parameter.DeleteSessionRemarkBean;
import com.ymatou.iapi.im.parameter.SendMessageToBuyerBean;
import com.ymatou.iapi.im.service.DeleteSessionRemarkCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymttest.business.service.ImCallService;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.sqlwapper.ImDefaultWapper;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;

import java.util.Map;

/**
*买手删除会话备注
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_DeleteSessionRemark{
	private static DeleteSessionRemarkBean deletesessionremarkBean;
	private static DeleteSessionRemarkCall deletesessionremarkCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("买手删除会话备注");
	}

	@Before
	public void caseUp() {
		deletesessionremarkBean=new DeleteSessionRemarkBean();
		deletesessionremarkCall=new DeleteSessionRemarkCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(deletesessionremarkCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_DeleteSessionRemark_01() {
		Logger.start(true,"取消会话免打扰");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			int fromUserId = 24635724;
			SendMessageToBuyerBean sendMessageToBuyerBean = ImCallService.initSendMessageToBuyerBean(fromUserId,userId,"nihao");
			ImCallService.SendMessageToBuyer(sendMessageToBuyerBean);
			//买手增加会话备注
			String msg = "nihaoa";
			ImCallService.SendSessionRemark(fromUserId,userId,msg);
			Map map = new ImDefaultWapper().selectTotalCount(userId,fromUserId).get(0);
			Logger.verifyEquals(msg,map.get("Remark").toString(),"验证是否添加备注");

			deletesessionremarkBean.setFromUserId(fromUserId);
			deletesessionremarkBean.setToUserId(userId);
			deletesessionremarkCall.setData(deletesessionremarkBean);
			deletesessionremarkCall.callService();
			Map map1 = new ImDefaultWapper().selectTotalCount(userId,fromUserId).get(0);
			Logger.verifyEquals(true,map1.get("Remark")==null?true:false,"验证是否已经删除备注");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}